﻿// iostream.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <iostream>

int main()
{
    //std:: 意思是使用iostream库中自带的关键字所需要的前缀
    //例如： std::cin >> 等同于c语言中的 scanf 输入
    //      std::cout << 等同于c语言中的 printf 打印输出
    //      << std::endl; 意为结束语句，把结果从缓冲区刷到设备中
    //      >> 输入运算符
    //      << 输出运算符
    

    /*输入两个数*/
    std::cout << "Enter tow numbers:" << std::endl;
    int v1 = 0, v2 = 0;
    std::cin >> v1 >> v2;
    //相加
    std::cout << "the sum of " << v1 << " and " << v2
        << " is " << v1 + v2 << std::endl;
    std::cout << "Hello World!\n";
    //相乘
    std::cout << "enter tow numbers" << std::endl;
    int v3 = 0; 
    int v4 = 0;
    std::cin >> v3;
    std::cin >> v4;
    std::cout << "the product of " << v3 << " and " << v4
        << " is " << v3 * v4 << std::endl;
    std::cout << "the sction is over";
    
    //while
    int sum = 0, val = 1;
    //只要val的值小于等于10，while循环就会持续执行
    //累加
    while (val <= 10)
    {
        sum += val;
        ++val;
    }
    std::cout << "Sum of 1 to 10 inclusive is "
        << sum << std::endl;
    //for
    int sum1 = 0;
    for (int val = 1; val <= 10; val++)
    {
        sum += val;
        std::cout << "sum of 1 to 10 inclusive is "
            << sum << std::endl;

    }
    //键盘输入并计算所有读入值的和
    int sum2 = 0, value = 0;
    while (std::cin >> value)
    {
        sum += value;
        std::cout << "sum is " << sum << std::endl;
    }

    

    //当输入value值符合条件时，条件始终为真，循环会一直持续，读取结束后等待下次检测
    //当输入不符合条件，即无效输入或者遇到结束符，就会判定为假，结束循环
    //当同时输入多个数据时，每读一个，进行一次循环，直到读完等待下次输入或者遇到结束符退出循环
    //文件结束符：在win系统中是CTRL + Z

   






    return 0;
}


